package com.itheima.stock.controller;


import com.itheima.stock.service.UserService;
import com.itheima.stock.vo.req.LoginReqVo;
import com.itheima.stock.vo.res.LoginRespVo;
import com.itheima.stock.vo.res.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api")
public class UserController {
    @Autowired
    private UserService userService;

    @GetMapping("/user/test")
    public String getName(){
        return "hello";
    }

    @PostMapping("/login")
    public R<LoginRespVo> login(@RequestBody LoginReqVo vo){

        System.out.println(vo);
//        R<LoginRespVo> r= this.userService.login(vo);


        return userService.login(vo) ;

    }


//    @GetMapping("/login")
//    public Object i(){
//        return userService.login(new LoginReqVo("admin", "123456", null, null)) ;
//    }

    @GetMapping("captcha")
    public R<Map> generateCode(){
        return userService.generateCode();
    }

}
